---
title: TwitchProvider
editUrl: https://github.com/toolbeam/openauth/blob/master/packages/openauth/src/provider/twitch.ts
description: Reference doc for the `TwitchProvider`.
---

import { Segment, Section, NestedTitle, InlineSection } from 'toolbeam-docs-theme/components'
import { Tabs, TabItem } from '@astrojs/starlight/components'

<div class="tsdoc">
<Section type="about">
Use this provider to authenticate with Twitch.

```ts {5-8}
import { TwitchProvider } from "@openauthjs/openauth/provider/twitch"

export default issuer({
  providers: {
    twitch: TwitchProvider({
      clientID: "1234567890",
      clientSecret: "0987654321"
    })
  }
})
```
</Section>
---
## Methods
### TwitchProvider
<Segment>
<Section type="signature">
```ts
TwitchProvider(config)
```
</Section>
<Section type="parameters">
#### Parameters
- <p><code class="key">config</code> [<code class="type">TwitchConfig</code>](/docs/provider/twitch#twitchconfig)</p>
The config for the provider.
</Section>
<InlineSection>
**Returns** <code class="type">Provider</code>
</InlineSection>
Create a Twitch OAuth2 provider.
```ts
TwitchProvider({
  clientID: "1234567890",
  clientSecret: "0987654321"
})
```
</Segment>
## TwitchConfig
<Segment>
<Section type="parameters">
- <p>[<code class="key">clientID</code>](#twitchconfig.clientid) <code class="primitive">string</code></p>
- <p>[<code class="key">clientSecret</code>](#twitchconfig.clientsecret) <code class="primitive">string</code></p>
- <p>[<code class="key">pkce?</code>](#twitchconfig.pkce) <code class="primitive">boolean</code></p>
- <p>[<code class="key">query?</code>](#twitchconfig.query) <code class="primitive">Record</code><code class="symbol">&lt;</code><code class="primitive">string</code>, <code class="primitive">string</code><code class="symbol">&gt;</code></p>
- <p>[<code class="key">scopes</code>](#twitchconfig.scopes) <code class="primitive">string</code><code class="symbol">[]</code></p>
</Section>
</Segment>
<NestedTitle id="twitchconfig.clientid" Tag="h4" parent="TwitchConfig.">clientID</NestedTitle>
<Segment>
<Section type="parameters">
<InlineSection>
**Type** <code class="primitive">string</code>
</InlineSection>
</Section>
The client ID.

This is just a string to identify your app.
```ts
{
  clientID: "my-client"
}
```
</Segment>
<NestedTitle id="twitchconfig.clientsecret" Tag="h4" parent="TwitchConfig.">clientSecret</NestedTitle>
<Segment>
<Section type="parameters">
<InlineSection>
**Type** <code class="primitive">string</code>
</InlineSection>
</Section>
The client secret.

This is a private key that's used to authenticate your app. It should be kept secret.
```ts
{
  clientSecret: "0987654321"
}
```
</Segment>
<NestedTitle id="twitchconfig.pkce" Tag="h4" parent="TwitchConfig.">pkce?</NestedTitle>
<Segment>
<Section type="parameters">
<InlineSection>
**Type** <code class="primitive">boolean</code>
</InlineSection>
</Section>

<InlineSection>
**Default** false
</InlineSection>
Whether to use PKCE (Proof Key for Code Exchange) for the authorization code flow.
Some providers like x.com require this.
</Segment>
<NestedTitle id="twitchconfig.query" Tag="h4" parent="TwitchConfig.">query?</NestedTitle>
<Segment>
<Section type="parameters">
<InlineSection>
**Type** <code class="primitive">Record</code><code class="symbol">&lt;</code><code class="primitive">string</code>, <code class="primitive">string</code><code class="symbol">&gt;</code>
</InlineSection>
</Section>
Any additional parameters that you want to pass to the authorization endpoint.
```ts
{
  query: {
    access_type: "offline",
    prompt: "consent"
  }
}
```
</Segment>
<NestedTitle id="twitchconfig.scopes" Tag="h4" parent="TwitchConfig.">scopes</NestedTitle>
<Segment>
<Section type="parameters">
<InlineSection>
**Type** <code class="primitive">string</code><code class="symbol">[]</code>
</InlineSection>
</Section>
A list of OAuth scopes that you want to request.
```ts
{
  scopes: ["email", "profile"]
}
```
</Segment>
</div>